﻿<%@ Page Title="Change Password" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Manage.aspx.vb" Inherits="WSAD_Assignment.Manage" %>
<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
<%--    <hgroup class="title">
        <h1><%: Title %>.</h1>
    </hgroup>--%>
    <h3 class="form-signup-heading"><%: Title %></h3>

    <section id="passwordForm">
        <asp:PlaceHolder runat="server" ID="successMessage" Visible="false" ViewStateMode="Disabled">
            <asp:Panel ID="pnlUserMessage" CssClass="bg-success" runat="server" Visible="false">
                <asp:Label ID="lblUserMessage" runat="server"><%: SuccessMessageText %></asp:Label>
            </asp:Panel>
            <%--<p class="message-success"><%: SuccessMessageText %></p>--%>
        </asp:PlaceHolder>

        <h4>You're logged in as <strong><%: User.Identity.Name %></strong>.</h4>

        <asp:PlaceHolder runat="server" ID="setPassword" Visible="false">
            <p>
                You do not have a local password for this site. Add a local
                password so you can log in without an external login.
            </p>
            <fieldset>
                <legend>Set password form</legend>
                <ol>
                    <li>
                        <asp:Label runat="server" AssociatedControlID="password">Password</asp:Label>
                        <asp:TextBox runat="server" ID="password" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="password"
                            CssClass="field-validation-error" ErrorMessage="The password field is required."
                            Display="Dynamic" ValidationGroup="SetPassword" />
                        
                        <asp:ModelErrorMessage runat="server" ModelStateKey="NewPassword" AssociatedControlID="password"
                            CssClass="field-validation-error" SetFocusOnError="true" />
                        
                    </li>
                    <li>
                        <asp:Label runat="server" AssociatedControlID="confirmPassword">Confirm password</asp:Label>
                        <asp:TextBox runat="server" ID="confirmPassword" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="confirmPassword"
                            CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The confirm password field is required."
                            ValidationGroup="SetPassword" />
                        <asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="confirmPassword"
                            CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match."
                            ValidationGroup="SetPassword" />
                    </li>
                </ol>
                <asp:Button runat="server" Text="Set Password" ValidationGroup="SetPassword" OnClick="setPassword_Click" />
            </fieldset>
        </asp:PlaceHolder>

        <asp:PlaceHolder runat="server" ID="changePassword" Visible="false">
            <%--<h3>Change password</h3>--%>
            <asp:ChangePassword runat="server" CancelDestinationPageUrl="~/" ViewStateMode="Disabled" RenderOuterTable="false" SuccessPageUrl="Manage?m=ChangePwdSuccess" >
                <ChangePasswordTemplate>

                    <p class="validation-summary-errors">
                        <asp:Literal runat="server" ID="FailureText" />
                    </p>
                    <fieldset class="changePassword">
                        <legend>Change password details</legend>
                        <ol>
                            <li>
                                <div class="form-group">
                                    <asp:Label ID="CurrentPasswordLabel" AssociatedControlID="CurrentPassword" runat="server" CssClass="col-sm-2 control-label" Text="Current Password"></asp:Label>

   		                            <div class="col-sm-4">
                                        <asp:TextBox ID="CurrentPassword" name="CurrentPassword" runat="server" CssClass="form-control passwordEntry" TextMode="Password" placeholder="Current Password"></asp:TextBox>
                                        <asp:RequiredFieldValidator runat="server" ControlToValidate="CurrentPassword"
                                            CssClass="field-validation-error" ErrorMessage="This field is required!"
                                            ValidationGroup="ChangePassword" />
   		                            </div>
                                </div> 
                            </li>
                            <li>
                                <div class="form-group">
                                    <asp:Label ID="NewPasswordLabel" AssociatedControlID="NewPassword" runat="server" CssClass="col-sm-2 control-label" Text="New Password"></asp:Label>

   		                            <div class="col-sm-4">
                                        <asp:TextBox ID="NewPassword" name="NewPassword" runat="server" CssClass="form-control passwordEntry" TextMode="Password" placeholder="New Password"></asp:TextBox>
                                        <asp:RequiredFieldValidator runat="server" ControlToValidate="NewPassword"
                                            CssClass="field-validation-error" ErrorMessage="This field is required!"
                                            ValidationGroup="ChangePassword" />
   		                            </div>
                                </div> 
                            </li>
                            <li>
                                <div class="form-group">
                                    <asp:Label ID="ConfirmNewPasswordLabel" AssociatedControlID="ConfirmNewPassword" runat="server" CssClass="col-sm-2 control-label" Text="Confirm New Password"></asp:Label>

   		                            <div class="col-sm-4">
                                        <asp:TextBox ID="ConfirmNewPassword" name="ConfirmNewPassword" runat="server" CssClass="form-control passwordEntry" TextMode="Password" placeholder="Confirm Password"></asp:TextBox>
                                        <asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmNewPassword"
                                            CssClass="field-validation-error" Display="Dynamic" ErrorMessage="This field is required!"
                                            ValidationGroup="ChangePassword" />
                                        <asp:CompareValidator runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword"
                                            CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The new password and confirmation password do not match!"
                                            ValidationGroup="ChangePassword" />
   		                            </div>
                                </div> 
                            </li>
                        </ol>

                        <div class="form-group">
                            <asp:LinkButton ID="btnChangePassword" 
                                runat="server"
                                CommandName="ChangePassword"
                                ValidationGroup="ChangePassword"
                                CssClass="btn btn-success"  
                                CausesValidation="true">
                                <i aria-hidden="true" class="glyphicon glyphicon-pencil"></i> Change Password
                            </asp:LinkButton>

                            <%--<asp:Button runat="server" CommandName="ChangePassword" Text="Change Password" ValidationGroup="ChangePassword" CssClass="btn btn-success"/>--%>
                        </div>

                    </fieldset>
                </ChangePasswordTemplate>
            </asp:ChangePassword>
        </asp:PlaceHolder>
    </section>

   <%-- <section id="externalLoginsForm">
        
        <asp:ListView runat="server"
            ItemType="Microsoft.AspNet.Membership.OpenAuth.OpenAuthAccountData"
            SelectMethod="GetExternalLogins" DeleteMethod="RemoveExternalLogin" DataKeyNames="ProviderName,ProviderUserId">
        
            <LayoutTemplate>
                <h3>Registered external logins</h3>
                <table>
                    <thead><tr><th>Service</th><th>User Name</th><th>Last Used</th><th>&nbsp;</th></tr></thead>
                    <tbody>
                        <tr runat="server" id="itemPlaceholder"></tr>
                    </tbody>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr>
                    
                    <td><%#: Item.ProviderDisplayName %></td>
                    <td><%#: Item.ProviderUserName %></td>
                    <td><%#: ConvertToDisplayDateTime(Item.LastUsedUtc) %></td>
                    <td>
                        <asp:Button runat="server" Text="Remove" CommandName="Delete" CausesValidation="false" 
                            ToolTip='<%#: "Remove this " & Item.ProviderDisplayName & " login from your account" %>'
                            Visible="<%# CanRemoveExternalLogins %>" />
                    </td>
                    
                </tr>
            </ItemTemplate>
        </asp:ListView>

        <h3>Add an external login</h3>
        <uc:OpenAuthProviders runat="server" ReturnUrl="~/Account/Manage" />
    </section>--%>

   

</asp:Content>
